﻿@model IEnumerable<RepertorySystem.Models.BookModels>
@Scripts.Render("~/bundles/jquery")
@{
    ViewBag.Title = "Index";
}
@{
    //获取端口
    IServiceProvider provider = (IServiceProvider)HttpContext.Current;
    HttpWorkerRequest request = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));
    var port = HttpContext.Current.Request.Url.Port;

}
<h2>书籍列表</h2>

<div class="col-lg-3 divfloat">
    <div class="input-group">
        <input id="searchInput" type="text" class="form-control" placeholder="输入书名" />
        <span class="input-group-btn">
            <input id="searchButton" class="btn btn-default" type="button" value="搜索" />
        </span>
    </div><!-- /input-group -->
</div>
<div id="a_Div"></div>
<script type="text/javascript">
    $("#searchButton").click(function(){
        var searchContent = $("#searchInput").val();

        if(searchContent == "" ){
            alert("请输入搜索内容");
        }else{
            window.location.href ="http://localhost:"+@port+"/Bookmodels/FindOne?book_Name="+searchContent;
        }
    });

</script>
<p>
    <span class="glyphicon glyphicon-plus" style="color: rgb(200, 153, 107); font-size: 15px;font-weight:bolder;"> @Html.ActionLink("添加新书", "Create")</span>
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Type)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.InPrice)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.OutPrice)
        </th>
        <th></th>
    </tr>
@if (ViewBag.content == null) {
    <tr>未查找到内容！</tr>
} else {
    foreach (var item in ViewBag.content) {
    <tr>
        <td>
            @item.Name
        </td>
        <td>
            @item.Type
        </td>
        <td>
            @item.InPrice
        </td>
        <td>
            @item.OutPrice
        </td>
        <td>
            <span class="glyphicon glyphicon-cog" style="color: rgb(200, 153, 107); font-size: 15px;"> @Html.ActionLink("编辑", "Edit", new { id = item.ID }) </span>
            |
            @*@Html.ActionLink("Details", "Details", new { id=item.ID }) |*@
            <span class="glyphicon glyphicon-trash" style="color: rgb(200, 153, 107); font-size: 15px;">  @Html.ActionLink("删除", "Delete", new { id = item.ID }) </span>

        </td>
    </tr>
    }
}

</table>
<div id="pagebar">
    <ul class="pagination">
       @for (var i = 0; i < ViewBag.totalPages; i++)
       {

           if (ViewBag.currentPage == (i + 1))
           {
            <li><span class="currentPage">@(i + 1)</span></li>
           }
           else
           {
               //<a class="nextOrPreviousPage" href="javascript:;">@(i + 1)</a>
               var number = i + 1;
            <li> @Html.ActionLink("" + number, "GetNext", new { currentPage = number });</li>
           }
       }
    </ul>
</div>

